home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Gobby 0.4.7 / gobby-0.4.7.exe / {app} / share / gtksourceview-2.0 / language-specs / python.lang < prev    next >
Extensible Markup Language  |  2008-09-09  |  13KB  |  350 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.  Author: Gustavo Gir├íldez <gustavo.giraldez@gmx.net>
  5.  Copyright (C) 2003 Gustavo Gir├íldez <gustavo.giraldez@gmx.net>
  6.  Copyright (C) 2004 Beno├«t Dejean <TaZForEver@free.fr>
  7.  Copyright (C) 2006 Steve Fr├⌐cinaux <nud@apinc.org>
  8.  
  9.  This library is free software; you can redistribute it and/or
  10.  modify it under the terms of the GNU Library General Public
  11.  License as published by the Free Software Foundation; either
  12.  version 2 of the License, or (at your option) any later version.
  13.  
  14.  This library is distributed in the hope that it will be useful,
  15.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.  Library General Public License for more details.
  18.  
  19.  You should have received a copy of the GNU Library General Public
  20.  License along with this library; if not, write to the
  21.  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  22.  Boston, MA 02111-1307, USA.
  23.  
  24. -->
  25. <language id="python" _name="Python" version="2.0" _section="Scripts">
  26.   <metadata>
  27.     <property name="mimetypes">text/x-python;application/x-python</property>
  28.     <property name="globs">*.py</property>
  29.     <property name="line-comment-start">#</property>
  30.   </metadata>
  31.  
  32.   <styles>
  33.     <style id="module-handler"    _name="Module Handler"        map-to="def:preprocessor"/>
  34.     <style id="keyword"           _name="Keyword"               map-to="def:keyword"/>
  35.     <style id="multiline-string"  _name="Multiline string"      map-to="def:string"/>
  36.     <style id="string"            _name="String"                map-to="def:string"/>
  37.     <style id="escaped-char"      _name="Escaped Character"     map-to="def:special-char"/>
  38.     <style id="format"            _name="Format"                map-to="def:character"/>
  39.     <style id="string-conversion" _name="string-conversion"/>
  40.     <style id="special-variable"  _name="Special Variable"      map-to="def:identifier"/>
  41.     <style id="boolean"           _name="Boolean"               map-to="def:boolean"/>
  42.     <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
  43.     <style id="decimal"           _name="Decimal number"        map-to="def:decimal"/>
  44.     <style id="base-n-integer"    _name="Base-N number"         map-to="def:base-n-integer"/>
  45.     <style id="complex"           _name="Complex number"        map-to="def:complex"/>
  46.     <style id="builtin-constant"  _name="Builtin Constant"      map-to="def:special-constant"/>
  47.     <style id="builtin-object"    _name="Builtin Object"        map-to="def:type"/>
  48.     <style id="builtin-function"  _name="Builtin Function"      map-to="def:builtin"/>
  49.   </styles>
  50.  
  51.   <definitions>
  52.     <define-regex id="identifier">[_a-zA-Z][_a-zA-Z0-9]*</define-regex>
  53.     <define-regex id="number">[1-9][0-9]*</define-regex>
  54.  
  55.     <!-- http://docs.python.org/lib/typesseq-strings.html -->
  56.     <context id="format" style-ref="format" extend-parent="false">
  57.       <match extended="true">
  58.         %                       # leading % sign
  59.         \(\%{identifier}\)?     # mapping key
  60.         [#0\-\ \+]*             # conversion flags
  61.         (\-?\%{number}|\*)?     # minimum field width
  62.         (\.(\-?\%{number}|\*))? # precision
  63.         (hlL)?                  # lentgh modifier
  64.         [diouxXeEfFgGcrs%]      # conversion type
  65.       </match>
  66.     </context>
  67.  
  68.     <!-- http://docs.python.org/ref/strings.html -->
  69.     <context id="escaped-char" style-ref="escaped-char" extend-parent="true">
  70.       <match extended="true">
  71.         \\(                 # leading backslash
  72.         [\\'"abfnrtv]     | # single escaped char
  73.         N\{[A-Z\ ]+\}     | # named unicode character
  74.         u[0-9A-Fa-f]{4}   | # xxxx - character with 16-bit hex value xxxx
  75.         U[0-9A-Fa-f]{8}   | # xxxxxxxx - character with 32-bit hex value xxxxxxxx
  76.         x[0-9A-Fa-f]{1,2} | # \xhh - character with hex value hh
  77.         [0-7]{1,3}          # \ooo - character with octal value ooo
  78.         )
  79.       </match>
  80.     </context>
  81.  
  82.     <define-regex id="string-prefix">(r|u|ur|R|U|UR|Ur|uR)?</define-regex>
  83.  
  84.     <context id="multiline-double-quoted-string" style-ref="multiline-string">
  85.       <start>\%{string-prefix}"""</start>
  86.       <end>"""</end>
  87.       <include>
  88.         <context ref="format"/>
  89.         <context ref="escaped-char"/>
  90.       </include>
  91.     </context>
  92.  
  93.     <context id="multiline-single-quoted-string" style-ref="multiline-string">
  94.       <start>\%{string-prefix}'''</start>
  95.       <end>'''</end>
  96.       <include>
  97.         <context ref="format"/>
  98.         <context ref="escaped-char"/>
  99.       </include>
  100.     </context>
  101.  
  102.     <context id="double-quoted-string" style-ref="string" end-at-line-end="true">
  103.       <start>\%{string-prefix}"</start>
  104.       <end>"</end>
  105.       <include>
  106.         <context ref="format"/>
  107.         <context ref="escaped-char"/>
  108.         <context ref="def:line-continue"/>
  109.       </include>
  110.     </context>
  111.  
  112.     <context id="single-quoted-string" style-ref="string" end-at-line-end="true">
  113.       <start>\%{string-prefix}'</start>
  114.       <end>'</end>
  115.       <include>
  116.         <context ref="format"/>
  117.         <context ref="escaped-char"/>
  118.         <context ref="def:line-continue"/>
  119.       </include>
  120.     </context>
  121.  
  122.     <context id="python">
  123.       <include>
  124.         <context ref="def:shebang"/>
  125.         <context ref="def:shell-like-comment"/>
  126.  
  127.         <context ref="multiline-double-quoted-string"/>
  128.         <context ref="multiline-single-quoted-string"/>
  129.         <context ref="double-quoted-string"/>
  130.         <context ref="single-quoted-string"/>
  131.  
  132.         <context id="string-conversion" style-ref="string-conversion" end-at-line-end="true">
  133.           <start>`</start>
  134.           <end>`</end>
  135.           <include>
  136.             <context ref="python"/>
  137.           </include>
  138.         </context>
  139.  
  140.         <context id="special-variables" style-ref="special-variable">
  141.           <prefix>(?<![\w\.])</prefix>
  142.           <keyword>self</keyword>
  143.           <keyword>__name__</keyword>
  144.           <keyword>__debug__</keyword>
  145.         </context>
  146.  
  147.         <context id="boolean" style-ref="boolean">
  148.           <prefix>(?<![\w\.])</prefix>
  149.           <keyword>False</keyword>
  150.           <keyword>True</keyword>
  151.         </context>
  152.  
  153.         <define-regex id="float" extended="true">
  154.           ( (\d+)?\.\d+ | \d+\. ) |
  155.           ( (\d+|(\d+)?\.\d+|\d+\.)[eE][+-]?\d+ )
  156.         </define-regex>
  157.  
  158.         <context id="complex" style-ref="complex">
  159.           <match>(?<![\w\.])(\%{float}|\d+)[jJ]\b</match>
  160.         </context>
  161.  
  162.         <context id="float" style-ref="floating-point">
  163.           <match>(?<![\w\.])\%{float}(?![\w\.])</match>
  164.         </context>
  165.  
  166.         <context id="decimal" style-ref="decimal">
  167.           <match>(?<![\w\.])([1-9][0-9]*|0)[lL]?(?![\w\.])</match>
  168.         </context>
  169.  
  170.         <context id="octal" style-ref="base-n-integer">
  171.           <match>(?<![\w\.])0[0-7]+[lL]?(?![\w\.])</match>
  172.         </context>
  173.  
  174.         <context id="hex" style-ref="base-n-integer">
  175.           <match>(?<![\w\.])0[xX][0-9A-Fa-f]+[lL]?(?![\w\.])</match>
  176.         </context>
  177.  
  178.         <context id="module-handler" style-ref="module-handler">
  179.           <keyword>import</keyword>
  180.           <keyword>from</keyword>
  181.           <keyword>as</keyword>
  182.         </context>
  183.  
  184.         <context id="keyword" style-ref="keyword">
  185.           <keyword>and</keyword>
  186.           <keyword>assert</keyword>
  187.           <keyword>break</keyword>
  188.           <keyword>class</keyword>
  189.           <keyword>continue</keyword>
  190.           <keyword>def</keyword>
  191.           <keyword>del</keyword>
  192.           <keyword>elif</keyword>
  193.           <keyword>else</keyword>
  194.           <keyword>except</keyword>
  195.           <keyword>exec</keyword>
  196.           <keyword>finally</keyword>
  197.           <keyword>for</keyword>
  198.           <keyword>global</keyword>
  199.           <keyword>if</keyword>
  200.           <keyword>in</keyword>
  201.           <keyword>is</keyword>
  202.           <keyword>lambda</keyword>
  203.           <keyword>not</keyword>
  204.           <keyword>or</keyword>
  205.           <keyword>pass</keyword>
  206.           <keyword>print</keyword>
  207.           <keyword>raise</keyword>
  208.           <keyword>return</keyword>
  209.           <keyword>try</keyword>
  210.           <keyword>while</keyword>
  211.           <keyword>yield</keyword>
  212.         </context>
  213.  
  214.         <context id="builtin-constants" style-ref="builtin-constant">
  215.           <prefix>(?<![\w\.])</prefix>
  216.           <keyword>Ellipsis</keyword>
  217.           <keyword>None</keyword>
  218.           <keyword>NotImplemented</keyword>
  219.         </context>
  220.  
  221.         <context id="builtin-objects" style-ref="builtin-object">
  222.           <prefix>(?<![\w\.])</prefix>
  223.           <keyword>ArithmeticError</keyword>
  224.           <keyword>AssertionError</keyword>
  225.           <keyword>AttributeError</keyword>
  226.           <keyword>EnvironmentError</keyword>
  227.           <keyword>EOFError</keyword>
  228.           <keyword>Exception</keyword>
  229.           <keyword>FloatingPointError</keyword>
  230.           <keyword>ImportError</keyword>
  231.           <keyword>IndentationError</keyword>
  232.           <keyword>IndexError</keyword>
  233.           <keyword>IOError</keyword>
  234.           <keyword>KeyboardInterrupt</keyword>
  235.           <keyword>KeyError</keyword>
  236.           <keyword>LookupError</keyword>
  237.           <keyword>MemoryError</keyword>
  238.           <keyword>NameError</keyword>
  239.           <keyword>NotImplementedError</keyword>
  240.           <keyword>OSError</keyword>
  241.           <keyword>OverflowError</keyword>
  242.           <keyword>ReferenceError</keyword>
  243.           <keyword>RuntimeError</keyword>
  244.           <keyword>StandardError</keyword>
  245.           <keyword>StopIteration</keyword>
  246.           <keyword>SyntaxError</keyword>
  247.           <keyword>SystemError</keyword>
  248.           <keyword>SystemExit</keyword>
  249.           <keyword>TabError</keyword>
  250.           <keyword>TypeError</keyword>
  251.           <keyword>UnboundLocalError</keyword>
  252.           <keyword>UnicodeDecodeError</keyword>
  253.           <keyword>UnicodeEncodeError</keyword>
  254.           <keyword>UnicodeError</keyword>
  255.           <keyword>UnicodeTranslateError</keyword>
  256.           <keyword>ValueError</keyword>
  257.           <keyword>WindowsError</keyword>
  258.           <keyword>ZeroDivisionError</keyword>
  259.  
  260.           <keyword>Warning</keyword>
  261.           <keyword>UserWarning</keyword>
  262.           <keyword>DeprecationWarning</keyword>
  263.           <keyword>PendingDeprecationWarning</keyword>
  264.           <keyword>SyntaxWarning</keyword>
  265.           <keyword>OverflowWarning</keyword>
  266.           <keyword>RuntimeWarning</keyword>
  267.           <keyword>FutureWarning</keyword>
  268.         </context>
  269.  
  270.         <context id="builtin-function" style-ref="builtin-function">
  271.           <prefix>(?<![\w\.])</prefix>
  272.           <keyword>__import__</keyword>
  273.           <keyword>abs</keyword>
  274.           <keyword>all</keyword>
  275.           <keyword>any</keyword>
  276.           <keyword>apply</keyword>
  277.           <keyword>basestring</keyword>
  278.           <keyword>bool</keyword>
  279.           <keyword>buffer</keyword>
  280.           <keyword>callable</keyword>
  281.           <keyword>chr</keyword>
  282.           <keyword>classmethod</keyword>
  283.           <keyword>cmp</keyword>
  284.           <keyword>coerce</keyword>
  285.           <keyword>compile</keyword>
  286.           <keyword>complex</keyword>
  287.           <keyword>delattr</keyword>
  288.           <keyword>dict</keyword>
  289.           <keyword>dir</keyword>
  290.           <keyword>divmod</keyword>
  291.           <keyword>enumerate</keyword>
  292.           <keyword>eval</keyword>
  293.           <keyword>execfile</keyword>
  294.           <keyword>file</keyword>
  295.           <keyword>filter</keyword>
  296.           <keyword>float</keyword>
  297.           <keyword>frozenset</keyword>
  298.           <keyword>getattr</keyword>
  299.           <keyword>globals</keyword>
  300.           <keyword>hasattr</keyword>
  301.           <keyword>hash</keyword>
  302.           <keyword>hex</keyword>
  303.           <keyword>id</keyword>
  304.           <keyword>input</keyword>
  305.           <keyword>int</keyword>
  306.           <keyword>intern</keyword>
  307.           <keyword>isinstance</keyword>
  308.           <keyword>issubclass</keyword>
  309.           <keyword>iter</keyword>
  310.           <keyword>len</keyword>
  311.           <keyword>list</keyword>
  312.           <keyword>locals</keyword>
  313.           <keyword>long</keyword>
  314.           <keyword>map</keyword>
  315.           <keyword>max</keyword>
  316.           <keyword>min</keyword>
  317.           <keyword>object</keyword>
  318.           <keyword>oct</keyword>
  319.           <keyword>open</keyword>
  320.           <keyword>ord</keyword>
  321.           <keyword>pow</keyword>
  322.           <keyword>property</keyword>
  323.           <keyword>range</keyword>
  324.           <keyword>raw_input</keyword>
  325.           <keyword>reduce</keyword>
  326.           <keyword>reload</keyword>
  327.           <keyword>repr</keyword>
  328.           <keyword>reversed</keyword>
  329.           <keyword>round</keyword>
  330.           <keyword>setattr</keyword>
  331.           <keyword>set</keyword>
  332.           <keyword>slice</keyword>
  333.           <keyword>sorted</keyword>
  334.           <keyword>staticmethod</keyword>
  335.           <keyword>str</keyword>
  336.           <keyword>sum</keyword>
  337.           <keyword>super</keyword>
  338.           <keyword>tuple</keyword>
  339.           <keyword>type</keyword>
  340.           <keyword>unichr</keyword>
  341.           <keyword>unicode</keyword>
  342.           <keyword>vars</keyword>
  343.           <keyword>xrange</keyword>
  344.           <keyword>zip</keyword>
  345.         </context>
  346.       </include>
  347.     </context>
  348.   </definitions>
  349. </language>
  350.